<?php

namespace app\model;

use think\Model;

class FourteenFeedPlan extends Model
{
    const IS_DELETE_NO = 0;
    const IS_LOOP_NO = 0; // 不循环
    const IS_LOOP_YES = 1; // 循环

    /**
     * @Description 根据out_id判断数据是否存在
     * @author: zj
     * @param int $factory_id
     * @param int $out_id
     * @time 2024/03/18 13:58:46
     * @return false|mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function checkOutIdIsExist(int $factory_id,int $out_id)
    {
        $info = $this->field('id')
            ->where('factory_id',$factory_id)
            ->where('out_id',$out_id)
            ->where('delete_time',self::IS_DELETE_NO)
            ->find();
        if (!$info) {
            return false;
        }

        return $info['id'];
    }

    /**
     * @Description 检查计划是否存在
     * @author: zj
     * @param int $factory_id
     * @param int $name
     * @time 2024/03/18 13:59:45
     * @return false|mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function checkNameIsExist(int $factory_id,int $name)
    {
        $info = $this->field('id')
            ->where('factory_id',$factory_id)
            ->where('name',$name)
            ->where('delete_time',self::IS_DELETE_NO)
            ->find();
        if (!$info) {
            return false;
        }

        return $info['id'];
    }

}